package suray.rgv.communication.data;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * 路径导航
 */
@NoArgsConstructor
@Data
public class RouteInfo {
    @JsonProperty("source_id")
    private String source_id;
    @JsonProperty("id")
    private String id;
    @JsonProperty("task_id")
    private String task_id;
    @JsonProperty("operation")
    private String operation;
    @JsonProperty("direction")
    private String direction;

    //将货叉移动到start_height高度，接着机器人移动到id点，然后机器人将货叉放到end_height，卸载货物
    @JsonProperty("start_height")
    private Float start_height;
    //到达id点后将货叉上升到的高度
    @JsonProperty("end_height")
    private Float end_height;
    //到达id点后将货叉前移距离，单位m
    @JsonProperty("fork_dist")
    private Float fork_dist;
    //去往id点的途中将货叉上升到指定的高度
    @JsonProperty("fork_mid_height")
    private Float fork_mid_height;
    //是否启用识别栈
    @JsonProperty("recognize")
    private Boolean recognize;
    @JsonProperty("recfile")
    private String recfile;

    @JsonProperty("angle")
    private Double angle;
    @JsonProperty("method")
    private String method;
    @JsonProperty("max_speed")
    private Double max_speed;
    @JsonProperty("max_wspeed")
    private Double max_wspeed;
    @JsonProperty("max_acc")
    private Double max_acc;
    @JsonProperty("max_wacc")
    private Double max_wacc;
    @JsonProperty("duration")
    private Integer duration;
    @JsonProperty("orientation")
    private Integer orientation;
    @JsonProperty("spin")
    private Boolean spin;
    @JsonProperty("use_pgv")
    private Boolean use_pgv;
    @JsonProperty("pgv_adjust_dist")
    private Double pgv_adjust_dist;
    @JsonProperty("pgv_adjust_cx")
    private Double pgv_adjust_cx;
    @JsonProperty("pgv_adjust_cy")
    private Double pgv_adjust_cy;
    @JsonProperty("script_args")
    private ScriptDTO script_args;

    @NoArgsConstructor
    @Data
    public static class ScriptDTO {
        @JsonProperty("mode")
        private String mode;
        //动作
        @JsonProperty("operation")
        private String operation;
        //运动方向
        @JsonProperty("direction")
        private String direction;
        //命令号
        @JsonProperty("task_num")
        private Integer task_num;
        //启动
        @JsonProperty("start")
        private Integer start;
        //起点条码高位
        @JsonProperty("start_codeH")
        private Integer start_codeH;
        //起点条码低位
        @JsonProperty("start_codeL")
        private Integer start_codeL;
        //终点条码高位
        @JsonProperty("end_codeH")
        private Integer end_codeH;
        //终点条码低位
        @JsonProperty("end_codeL")
        private Integer end_codeL;
        //节点个数
        @JsonProperty("node_num")
        private Integer node_num;
        //节点间隔距离
        @JsonProperty("interval_dist")
        private List<Integer> interval_dist;
        //运动加速度
        @JsonProperty("accelerate_speed")
        private Integer accelerate_speed;
        //运动减速度
        @JsonProperty("decelerate_speed")
        private Integer decelerate_speed;
        //速度
        @JsonProperty("speed")
        private Integer speed;
        //升降加速度
        @JsonProperty("accelerate_lift")
        private Integer accelerate_lift;
        //升降减速度
        @JsonProperty("decelerate_lift")
        private Integer decelerate_lift;
        //升降速度
        @JsonProperty("speed_lift")
        private Integer speed_lift;
        //动作确认，清除当前的动作结果
        @JsonProperty("action_conf")
        private Integer action_conf;
        @JsonProperty("fault_confirm")
        private Integer fault_confirm;
        //动作确认，清除当前的动作结果
        @JsonProperty("life")
        private Integer life;

        /*********************************************任务信息***********************************************/

        //1表示左侧；3表示右侧；
        @JsonProperty("taskDirection")
        private Integer taskDirection;

        //有效距离的个数
        @JsonProperty("nodeNum")
        private Integer nodeNum;

        //原点条码值H
        @JsonProperty("originalCodeH")
        private Integer originalCodeH;

        //原点条码值L
        @JsonProperty("originalCodeL")
        private Integer originalCodeL;

        //地图节点信息，长度30
        @JsonProperty("nodeInfo")
        private List<NodeInfo> nodeInfo;

        //任务编号, 每下发一个任务，此任务编号增1，循环递增；取值范围：1~255
        @JsonProperty("taskId")
        private Integer taskId;

        //启动任务, 写1开始执行任务
        @JsonProperty("startTask")
        private Integer startTask;

        //段序号, 小车行驶的目标位置对应的段序号
        @JsonProperty("segment")
        private Integer segment;

        //任务节点个数, taskInfo长度 * 2
        @JsonProperty("taskNodeNum")
        private Integer taskNodeNum;

        @JsonProperty("taskInfo")
        private List<TaskInfo> taskInfo;

        /*************************************************************************************************/
    }
    @JsonProperty("script_name")
    private String script_name;

    @Data
    public static class TaskInfo {
        //位置, nodeInfo中对应位置的下标
        Integer location;
        //动作
        Integer action;

        public TaskInfo(Integer location, Integer action) {
            this.location = location;
            this.action = action;
        }
    }

    @Data
    public static class NodeInfo {
        //地码
        private Integer codeH;
        private Integer codeL;
        //位移量
        private Integer distance;

        public NodeInfo(Integer codeH, Integer codeL, Integer distance) {
            this.codeH = codeH;
            this.codeL = codeL;
            this.distance = distance;
        }
    }
}
